Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/kill button - adding the kill button on top of NodeTree #500

Merged
merged 11 commits into from
Oct 19, 2023

Conversation

mikibonacci
Copy link
Member

@mikibonacci mikibonacci commented Oct 9, 2023

Fixes #161

adding the kill button to support live-killing of a workchain, just selecting it from the list and clicking on the button.

@mikibonacci mikibonacci requested a review from unkcpz October 9, 2023 10:20
Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mikibonacci. Just two small comments.

src/aiidalab_qe/common/process.py Outdated Show resolved Hide resolved
src/aiidalab_qe/common/process.py Outdated Show resolved Hide resolved
@unkcpz
Copy link
Member

unkcpz commented Oct 9, 2023

adding the kill button to support live-killing of a workchain, just selecting it from the list and clicking on the button.

I think for this button, it should be only enabled only when the workchain is in "running" state, so the state of the button should be update when the new process is selected from the workchain selector list.

@codecov
Copy link

codecov bot commented Oct 9, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (74a1965) 78.60% compared to head (80632a5) 80.99%.

❗ Current head 80632a5 differs from pull request most recent head df1d435. Consider uploading reports for the commit df1d435 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #500      +/-   ##
==========================================
+ Coverage   78.60%   80.99%   +2.39%     
==========================================
  Files          44       45       +1     
  Lines        3160     3805     +645     
==========================================
+ Hits         2484     3082     +598     
- Misses        676      723      +47     
Flag Coverage Δ
python-3.10 80.99% <64.28%> (+2.39%) ⬆️
python-3.8 81.03% <64.28%> (+2.38%) ⬆️
python-3.9 81.03% <64.28%> (+2.38%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/aiidalab_qe/common/process.py 85.71% <ø> (ø)
src/aiidalab_qe/app/result/__init__.py 81.25% <64.28%> (-7.33%) ⬇️

... and 14 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@danielhollas
Copy link
Contributor

Cool, I might steal this, wanted to have this feature for a while :-) Hower, my plan was to implement the button next somewhere next to the NodeTree widget of a running process. It seems a bit out of place in the Workchain selector, I would worry about accidentally clicking it. WDYT?

@unkcpz
Copy link
Member

unkcpz commented Oct 9, 2023

It seems a bit out of place in the Workchain selector, I would worry about accidentally clicking it. WDYT?

@danielhollas thanks a lot for chime in. It is a great point. My plan was to bring in this concept to the QeApp and we think about the layout afterward.
For the misclick, I won't worry about it too much, the window-close icon contains the cross, so I suppose the user will notice it will cause some fatal consequence (although we can not predict too much but how fatal it can be?). You idea of put it in the node tree is great, but I am afraid it is straightforward to implement especially when we have some issues concerned about improve the nodetree in general.

@danielhollas
Copy link
Contributor

Just to clarify, I did not mean to implement it directly in the Node tree widget, just as a simple standalone button somewhere next to it. You also highlight an important point, having just an icon without any explanation is very cryptic, whereas an big red scary "Kill workflow" button would be more obvious.

@mikibonacci
Copy link
Member Author

Dear @danielhollas thank you for your feedback! indeed, I think that the button should be somewhere near the workchain tree. Maybe for this release we can still have the button near the other two (new and refresh), and then in the future put it in a more reasonable place?

Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more minor thing to change, others are all good to me.

Comment on lines 86 to 92
ipw.dlink(
(self, "value"),
(self.kill_work_chains_button, "disabled"),
lambda workchain: orm.load_node(workchain).is_terminated
if isinstance(workchain, int)
else True,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using dlink, I think it is more proper to set the disable of the button in the callback function _observe_value. Because:

  1. the dlink is a bit complex with the transform from uuid to the running status, which will be clear if it is a regular code block in the function.
  2. In the refresh_work_chain method, the disable of the button is check and set, this has the same logic as dlink here and the refresh should trigger the callback (it is already the case I assume, if not we need to fix it).

Copy link
Member Author

@mikibonacci mikibonacci Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moving the disabling of the kill button into the _observe_value method.
However, in the init method I had to add the disabling, otherwise if
the browser page is refreshed (or loaded for the first time), it will not be
automatically disabled. I still do not understand why, but it works and the logic is not too involved.
@unkcpz please let me know if there is a smarter way to do it!

@unkcpz
Copy link
Member

unkcpz commented Oct 10, 2023

Just to clarify, I did not mean to implement it directly in the Node tree widget, just as a simple standalone button somewhere next to it.

I see, sorry for misunderstanding it. I guess you mean add it here,

self.node_view = AiidaNodeViewWidget(layout={"width": "auto", "height": "auto"})
ipw.dlink(
(self.process_tree, "selected_nodes"),
(self.node_view, "node"),
transform=lambda nodes: nodes[0] if nodes else None,

I can see the advantage of putting the button here, but I also thing having the kill button with "new", "refresh" is compatible with its usage. Let's discuss this in the meeting and see what others think.

@mikibonacci mikibonacci changed the title Feature/kill button Feature/kill button - adding the kill button on top of NodeTree Oct 12, 2023
@unkcpz
Copy link
Member

unkcpz commented Oct 16, 2023

Hi @mikibonacci, as we discussed during the meeting, we agree on that this button better to be placed above the node tree. Can you move it to there, thanks.

@unkcpz unkcpz closed this Oct 16, 2023
@unkcpz unkcpz reopened this Oct 16, 2023
@mikibonacci
Copy link
Member Author

Kill button now is in the step 4, just above the NodeTree. Also, if no workchain is shown, the button is not shown either. And is enabled only if the workchain is running/waiting/created.

@unkcpz @danielhollas
Screenshot from 2023-10-17 16-38-05

@unkcpz unkcpz force-pushed the feature/kill_button branch from e1b42a3 to df1d435 Compare October 19, 2023 16:24
Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had an offline pair coding and tidying up a bit on the implementation. All good from me. Thanks a lot! @mikibonacci

@unkcpz unkcpz merged commit c8d1283 into main Oct 19, 2023
10 checks passed
@unkcpz unkcpz deleted the feature/kill_button branch October 19, 2023 16:29
@danielhollas
Copy link
Contributor

danielhollas commented Oct 19, 2023 via email

@unkcpz
Copy link
Member

unkcpz commented Oct 20, 2023

Here it is:
image

We just made the component in but didn't spend time on the layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add button to kill the job
3 participants